package com.test.util;

import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateHelper {

	private static SessionFactory mySessionFactory; // singleton

	static {
		try {
			mySessionFactory = new Configuration().configure()
					.buildSessionFactory();
		} catch (Throwable ex) {
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {

		return mySessionFactory;
	}

	public static void close() {
		// release all (connection pools, cache ...)
		mySessionFactory.close();
	}
}
